function [ind] = transform(pr_vec, randv)
% takes pr_v :n by firm_num and random v: m by firm_num
% generate ind for each m on grid of [1:n]
% randv = SIM.ads(:,:,1)';
randv_mat = repmat(randv,size(pr_vec,1),1);
randv_final = reshape(randv_mat,size(randv,1),size(pr_vec,1),size(randv,2));
pr_vec_mat = reshape(repmat(cumsum(pr_vec),size(randv,1),1),size(pr_vec,1),size(randv,1),size(pr_vec,2));
pr_vec_mat = permute(pr_vec_mat,[2 1 3]);
compare = randv_final > pr_vec_mat;
ind = sum(compare,2)+1;
ind = squeeze(ind)';
% output is m by firm_num
end